home *** CD-ROM | disk | FTP | other *** search
/ Unreal Tournament Game Programming for Teens / UnrealTournamentGameProgrammingForTeens.iso / Chapter Files / Chapter10 / UT2004 / Ch09Disco / Classes / DiscoLightTriggerC.uc < prev    next >
Encoding:
Text File  |  2006-10-29  |  2.8 KB  |  96 lines

  1. //================================================================
  2. // DiscoLightTriggerC.
  3. // See DiscoLightTriggerC.txt
  4. //================================================================
  5. class DiscoLightTriggerC extends Trigger placeable;
  6.  
  7. var private bool Toggle;
  8. const QUOTES = 10;
  9. var private string GrouchoSays[QUOTES];
  10.  
  11.  
  12. //# 1
  13. function PostBeginPlay(){
  14.      SetQuotes();
  15.  
  16. }
  17.  
  18. function Touch( Actor Other )
  19. {
  20.      local TriggerLight SomeTriggerLight;
  21.      // #1 access the base class Message data member
  22.      // Assign a value using a newly defined function 
  23.      Message = GetMessage();
  24.      if ( ReTriggerDelay > 0 ){
  25.        if ( Level.TimeSeconds - TriggerTime < ReTriggerDelay ){
  26.               return;
  27.           }
  28.        TriggerTime = Level.TimeSeconds;
  29.      }//end if
  30.      
  31.      foreach DynamicActors( class 'TriggerLight', SomeTriggerLight, Event){
  32.         SomeTriggerLight.Trigger(Other, Other.Instigator);
  33.      } 
  34.      //#2 Access the message value
  35.      if( (Message != "") && (Other.Instigator != None) ){
  36.           // Send a string message to the toucher.
  37.           Other.Instigator.ClientMessage( Message );
  38.      }
  39.      if (RepeatTriggerTime > 0){
  40.           SetTimer(RepeatTriggerTime, false);
  41.      }
  42. }//end Touch
  43. // #2 Provide a message
  44. private function string GetMessage(){
  45.      local string Quote;
  46.      if(Toggle == False){
  47.          //Quote = "Change the lights!";
  48.          Quote = GetQuote();
  49.  
  50.      }else{
  51.          Quote = "";
  52.      }  
  53.      return Quote;
  54. }
  55.  
  56.  
  57.  
  58. // #3
  59. private function string GetQuote(){
  60.  
  61.      local int QuoteNumber;
  62.      local string WhatHeSays;
  63.     
  64.      QuoteNumber = Rand(QUOTES);
  65.     
  66.      if(QuoteNumber <= QUOTES ){
  67.          WhatHeSays = GrouchoSays[QuoteNumber];
  68.      }
  69.      return WhatHeSays;
  70. }
  71.  
  72.  
  73. // #4 
  74. private function SetQuotes(){ 
  75.    GrouchoSays[0] = "Either he's dead or my watch has stopped. ";
  76.    GrouchoSays[1] = "And I want to thank you for all the " $
  77.                  "enjoyment you've taken out of it. "; 
  78.    GrouchoSays[2] =    "All people are born alike - " $
  79.                     "except Republicans and Democrats. "; 
  80.    GrouchoSays[3] =    "I don't care to belong to a club that " $
  81.                     "accepts people like me as members. "; 
  82.    GrouchoSays[4] =    "I must confess, I was born at a very early age. "; 
  83.    GrouchoSays[5] =  "I worked my way up from nothing "$
  84.                      "to a state of extreme poverty. ";
  85.    GrouchoSays[6] =  "Military intelligence is a contradiction in terms. "; 
  86.    GrouchoSays[7] =  "No man goes before his time - " $
  87.                      "unless the boss leaves early. ";
  88.    GrouchoSays[8] =  "The secret of life is honesty and fair dealing." $
  89.                      " If you can fake that, you've got it made. ";
  90.    GrouchoSays[9] =  "A hospital bed is a parked taxi with the meter running. ";
  91. }
  92.  
  93. defaultproperties
  94. {
  95. }
  96.